<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="file" id='file'>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
    <script>
        const file = document.querySelector('#file');
        const formdata = new FormData();
        file.addEventListener('change', (e) => {
            const f = e.target.files[0]
            formdata.append('avatar', f);
            axios.post('http://120.24.80.83:3000/user/uploadAvatar', formdata, {headers: {Authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjcsInVzZXJuYW1lIjoiaGNobHEiLCJhdmF0YXIiOm51bGwsIm1vbmV5IjowLCJjcmVhdGVfdGltZSI6IjIwMjEtMDctMThUMDU6MTE6MDIuMDAwWiIsInJvbGUiOiJ0ZWFjaGVyIiwiaWF0IjoxNjI2NTg1MTEzLCJleHAiOjE2MjY2MTUxMTN9.siXRvRerWmV5AIMAZgS6j7yHd11ZMOvVvb04Y7V9rhs'}}).then(res => {
                console.log(res.data)
            })
        })


    </script>
</body>
</html>